package de.bloxel.util;

import com.jme3.math.ColorRGBA;

/**
 * @author andreas
 * @since 0.1.0
 */
public final class ColorRGBAUtils {

  /**
   * Convert the given hexcode (html-color) to ColorRGBA.
   * 
   * See http://en.wikipedia.org/wiki/Web_colors
   * 
   * @param hex
   * @return
   */
  public static ColorRGBA hexToRGBA(final String hex) {
    final int rgb = Integer.parseInt(hex, 16);
    final float red = (rgb >> 16) & 0xFF;
    final float green = (rgb >> 8) & 0xFF;
    final float blue = rgb & 0xFF;
    return new ColorRGBA(red / 255f, green / 255f, blue / 255f, 1f);
  }
}